home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / gufw / model / Firewall.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2009-11-02  |  5KB  |  134 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from FrontEnd import Frontend
  5. from Log import Log
  6. from Variable import Variable
  7.  
  8. class Firewall:
  9.     
  10.     def __init__(self):
  11.         self.rules_list = []
  12.         self.frontend = Frontend()
  13.         self.log = Log()
  14.         self.variable = Variable()
  15.         self.status = self.frontend.get_status()
  16.         self.default = self.frontend.get_default()
  17.         self.ufw_log = self.frontend.get_ufw_log()
  18.         self.gufw_log = self.frontend.get_gufw_log()
  19.         self.wrap = self.log.get_wrapping()
  20.         self.maximized = False
  21.  
  22.     
  23.     def set_status(self, status):
  24.         self.status = self.frontend.set_status(status)
  25.         self.log.add_log(self.gufw_log, self.variable.get_command(status))
  26.  
  27.     
  28.     def get_status(self):
  29.         return self.status
  30.  
  31.     
  32.     def set_default(self, default):
  33.         self.default = self.frontend.set_default(default)
  34.         self.log.add_log(self.gufw_log, self.variable.get_command(default))
  35.  
  36.     
  37.     def get_default(self):
  38.         return self.default
  39.  
  40.     
  41.     def get_rules_list(self):
  42.         self.rules_list = []
  43.         rules = self.frontend.get_rules()
  44.         for rule in rules:
  45.             self.rules_list.append(self.get_rule_split_by_action(rule))
  46.         
  47.         return self.rules_list
  48.  
  49.     
  50.     def refresh_log(self):
  51.         self.log.refresh_log()
  52.  
  53.     
  54.     def get_log(self):
  55.         return self.log.get_log()
  56.  
  57.     
  58.     def get_wrap(self):
  59.         return self.log.get_wrapping()
  60.  
  61.     
  62.     def set_wrap(self, wrapping):
  63.         self.wrap = self.log.set_wrapping(wrapping)
  64.  
  65.     
  66.     def get_ufw_log(self):
  67.         return self.ufw_log
  68.  
  69.     
  70.     def set_ufw_log(self, status):
  71.         self.ufw_log = self.frontend.set_ufw_log(status)
  72.         self.log.add_log(self.gufw_log, self.variable.get_command(status))
  73.  
  74.     
  75.     def get_gufw_log(self):
  76.         return self.gufw_log
  77.  
  78.     
  79.     def set_gufw_log(self, status):
  80.         self.gufw_log = self.frontend.set_gufw_log(status)
  81.         if self.gufw_log == self.variable.get_constant('gufw_log_on'):
  82.             self.log.add_log(self.gufw_log, self.variable.get_text('004'))
  83.         else:
  84.             self.log.add_log('gufw_log_on', self.variable.get_text('005'))
  85.  
  86.     
  87.     def add_rule(self, service, action, protocol, fromip, fromport, toip, toport):
  88.         rule = self.frontend.add_rule_component(service, action, protocol, fromip, fromport, toip, toport)
  89.         self.log.add_log(self.gufw_log, rule)
  90.         return self.frontend.add_rule(rule)
  91.  
  92.     
  93.     def remove_rule(self, rule_to, action, rule_from):
  94.         rule = self.frontend.remove_rule_component(rule_to, action, rule_from)
  95.         self.log.add_log(self.gufw_log, rule)
  96.         return self.frontend.remove_rule(rule)
  97.  
  98.     
  99.     def get_rule_split_by_action(self, rule):
  100.         return_split_rule = []
  101.         if rule.find(self.variable.get_constant('deny_upper')) != -1:
  102.             split_rule = rule.split(self.variable.get_constant('deny_upper'))
  103.             return_split_rule.append(split_rule[0].strip())
  104.             return_split_rule.append(self.variable.get_constant('deny_upper'))
  105.             return_split_rule.append(split_rule[1].strip())
  106.         elif rule.find(self.variable.get_constant('allow_upper')) != -1:
  107.             split_rule = rule.split(self.variable.get_constant('allow_upper'))
  108.             return_split_rule.append(split_rule[0].strip())
  109.             return_split_rule.append(self.variable.get_constant('allow_upper'))
  110.             return_split_rule.append(split_rule[1].strip())
  111.         elif rule.find(self.variable.get_constant('limit_upper')) != -1:
  112.             split_rule = rule.split(self.variable.get_constant('limit_upper'))
  113.             return_split_rule.append(split_rule[0].strip())
  114.             return_split_rule.append(self.variable.get_constant('limit_upper'))
  115.             return_split_rule.append(split_rule[1].strip())
  116.         elif rule.find(self.variable.get_constant('reject_upper')) != -1:
  117.             split_rule = rule.split(self.variable.get_constant('reject_upper'))
  118.             return_split_rule.append(split_rule[0].strip())
  119.             return_split_rule.append(self.variable.get_constant('reject_upper'))
  120.             return_split_rule.append(split_rule[1].strip())
  121.         
  122.         return return_split_rule
  123.  
  124.     
  125.     def get_old_size_window(self):
  126.         (width, height) = self.frontend.get_old_size_window()
  127.         return (width, height)
  128.  
  129.     
  130.     def save_size_window(self, win_width, win_height):
  131.         self.frontend.save_size_window(win_width, win_height)
  132.  
  133.  
  134.